#!/bin/bash

. scripts/envVar.sh
. scripts/utils.sh

CHANNEL="channel1"
NUM="$1"

checkBlock() {
    infoln "Fetching '$NUM' block for channel1"
    setGlobals 1

    infoln "Fetching the '$NUM' block for the channel"
    set -x
    peer channel fetch $NUM block1.pb -o orderer.project.com:7050 --ordererTLSHostnameOverride orderer.project.com -c $CHANNEL --tls --cafile "$ORDERER_CA"
    { set +x; } 2>/dev/null

    infoln "Decoding config block to JSON"
    set -x
    configtxlator proto_decode --input block1.pb --type common.Block --output ${NUM}Block1.json
}

checkBlock